package com.cskaoyan.javase.oop2._1extend._6initialization._2question;

/**
 * @description: 为什么this/super在调用构造方法时都要求在第一行?
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

/**
 * 因为第一行如果没有super/this调用别的构造方法都会隐含super()
 * 这样如果后面还有super/this调用构造方法,会导致多次调用父类构造器,这显然是错误的
 *
 */
public class Demo {
    public static void main(String[] args) {

    }
}
class Father{
    int a;

    public Father(int a) {
        this.a = a;
    }

    public Father() {
    }
}
class Son extends Father{
    int b;

    public Son() {
    }

    public Son(int a) {
        //super()
        //System.out.println();
        super(a); //this()
    }

    public Son(int a, int b) {
        super(a);
        this.b = b;
    }

    //public Son(int b)

}